define(function (require, exports, module) {

  require("mixins/global.mixins.js");
  var mCard = require('andrew/card/index.js')


  var api = require('service/api.js');

  var pageVue = new Vue({
    data: {
      tableList: [],
      searchForm: {
        id: null,
        name: null,
        parentCategoryId: null,
        categoryId: null,
        dataFlag: 1
      },
      dataFlagEnum: [],
      SimpleCategoryTree: [],
      SimpleCategoryList: [],
      selectedOptions: [],
      formCollapse: false,
      OneCategoryList: [],
      TwoCategoryList: []
    },
    mounted: function () {
      this.getOneCategoryList();
      this.getDataList();
      console.log(this.Enum);
    },
    methods: {
      getOneCategoryList: function () {
          var curPageVue = this;
          api.queryCategoryList({
              params: {
                  pId: 0
              },
              callBack: function (res) {
                  curPageVue.OneCategoryList = res;
                  console.log('SimpleCategoryList');
                  console.log(res);

              }
          })
      },
      getChildrenCategoryList: function (id) {
        var curPageVue = this;
        api.queryCategoryList({
            params: {
                pId: id
            },
            callBack: function (res) {
                curPageVue.TwoCategoryList = res;
                console.log('SimpleCategoryList');
                console.log(res);
            }
        })
      },
      categoryChange: function (val) {
          this.searchForm.categoryId = null;
          this.searchForm.TwoCategoryList = [];
          this.getChildrenCategoryList(val);
      },
      handleChange: function (value) {
        console.log(value);
      },
      clearSearch: function () {
          this.searchForm.id = null;
          this.searchForm.dataFlag = null;
          this.searchForm.categoryId = null;
          this.searchForm.parentCategoryId = null;
          this.selectedOptions = [null];
      },
      clearThenSearch: function () {
        this.clearSearch();
        this.getDataList();
      },
      toggleSearhBodyCollapse: function () {
        this.formCollapse = !this.formCollapse;
      },
      onSubmit: function () {
        this.getDataList();
      },
      getDataList: function () {
        var curPageVue = this;
        var query = {};
        if (curPageVue.searchForm.id != null && curPageVue.searchForm.id.length > 0) {
          query['id'] = curPageVue.searchForm.id;
        }
        if (curPageVue.searchForm.dataFlag != null && curPageVue.searchForm.dataFlag > 0) {
          query['dataFlag'] = curPageVue.searchForm.dataFlag;
        }
        if (curPageVue.searchForm.categoryId != null && curPageVue.searchForm.categoryId > 0) {
          query['id'] = curPageVue.searchForm.categoryId;
        }
        if (curPageVue.searchForm.parentCategoryId != null && curPageVue.searchForm.parentCategoryId >= 0) {
          query['pId'] = curPageVue.searchForm.parentCategoryId;
        }
        console.log(query);

        api.getCategorySunList({
          params: query,
          callBack: function (res) {
            curPageVue.tableList = res;
            console.log(res);
          }
        })
      }
    }

  }).$mount('#app')
})
